package com.zmn.plat.admin.controller.service;

import javax.annotation.Resource;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.zmn.plat.business.interfaces.service.item.ServiceItemBService;
import com.zmn.plat.model.entity.servcategory.ServTariffAssCategoryQuery;
import com.zmn.plat.model.entity.service.tariff.ServiceTariff;
import com.zmn.plat.model.vo.service.item.ServicePageVO;
import com.zmn.plat.services.interfaces.service.tariff.ServiceTariffService;

/**
 * @author tanbiao
 * @description:故障项目管理入口
 * @since 2019/11/25 10:48
 * @modifier
 **/
@RequestMapping("/service/")
@Controller
public class ServiceListController {
    @Resource
    private ServiceItemBService faultItemBService;
    @Resource
    private ServiceTariffService faultTariffService;

    /**
     * 列表:以后台产品一级分类为维度进行列表展示，需要按照一级分类分组分页
     *
     * @param query
     * @author tanbiao
     * @since 2019-11-21 18:56:50
     */
    @RequestMapping("list")
    @RequiresPermissions("/service/list.action")
    public ModelAndView list(@ModelAttribute ServTariffAssCategoryQuery query) {
        ServicePageVO faultPageVO = faultItemBService.listPageByQuery(query);
        ServiceTariff tariff = faultTariffService.findByKey(query.getTariffId());
        ModelAndView mav = new ModelAndView("service/list");
        mav.addObject("items", faultPageVO.getItems());
        mav.addObject("vo", query);
        mav.addObject("faultTariff", tariff);
        mav.addObject("flag", query.getFlag());
        mav.addObject("servCategories", faultPageVO.getServCategories());
        mav.addObject("baseCategories", faultPageVO.getBaseCategories());
        return mav;
    }

}
